function twoSum(nums: number[], target: number): number[] {
    const map = new Map<number, number>();
    // key value
    // has() 传key 键值对
    // nums[index]作为键 index作为值
    // + string -> number

    for(const index in nums) {
        const diff = target - nums[index]

        if(map.has(diff)){
            return [map.get(diff), +index];
        }

        map.set(nums[index],+index);
    }

    return []
}

const nums7 = [2,7,11,15], target7 = 9

const result = twoSum(nums7,target7);

console.log(result);